package com.class04.ioc_04;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class JavaBean {
    //    方案一：直接赋值
    //    方案二：注解赋值  @Value注解  直接赋值  读取外部配置
//    默认值语法
//    @Value(${key:value默认值})
    private String name = "张三";
    @Value("19")
    public int age;
    @Value("${class04.usernam:admin}")
    public String username;
    @Value("${class04.password}")
    public String password;

    @Override
    public String toString() {
        return "JavaBean{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
